package com.five.core.utils;


import javax.servlet.http.HttpServletResponse;

/**
 * Created by shelei on 2024/10/18
 */
public class ResponseUtils {

    public static void responseToJson(HttpServletResponse response, String json){
        try{
            //告诉浏览器我先现在给你响应的是一个json类型的字符串
            response.setContentType("application/json;charset=UTF-8");
            //发送JSON
            response.getWriter().write(json);
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("Json发送失败!");
        }
    }

}
